App({
  globalData: {
    habits: []
  },
  onLaunch() {
    
    // 从本地存储加载习惯数据
    const savedHabits = wx.getStorageSync('habits');
    if (savedHabits) {
      try {
        this.globalData.habits = JSON.parse(savedHabits);
      } catch (e) {
        console.error('Failed to parse habits from storage', e);
        this.globalData.habits = [];
      }
    }
  },
  // 保存习惯数据到本地存储
  saveHabits() {
    try {
      wx.setStorageSync('habits', JSON.stringify(this.globalData.habits));
    } catch (e) {
      console.error('Failed to save habits', e);
    }
  }
})